# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :FileOpt.py
# @Time      :2022/3/11 23:53
# @Author    :Yongbo Zhou
import os


# 读取当前目录得文件  或者当前路径文件
def read_now_file(path):
    if os.path.isfile(path):
        return [path]
    for root, dirs, files in os.walk(path):
        return [(os.path.join(root, file)) for file in files]
    pass


# 返回文本所有得行
def read_file(file_path):
    if os.path.isdir(file_path):
        raise Exception('此路径非文件=>PATH:{}'.format(file_path))
    return [(line) for line in open(file=file_path, encoding='utf-8')]


if __name__ == '__main__':
    # print(read_now_file('D:\msg-log'))
    arr = read_now_file('D:\\msg-log')
    print(len(arr))
    pass
